﻿$.ajaxSetup({ cache: false });


function login() {
    if ($('#txtAccount').val() == '' || $('#txtPassword').val() == '') {
        alert('请输入用户名或密码!'); return false;
    }

    $.ajax({
        type: "POST",
        contentType: "application/json", //WebService 会返回Json类型
        url: "Services/PortalService.asmx/Login", //调用WebService的地址和方法名称组合 ---- WsURL/方法名
        data: "{Account:'" + $('#txtAccount').val() + "',Password:'" + $('#txtPassword').val() + "'}",
        dataType: 'json',
        beforeSend: function(XMLHttpRequest) {
            //            $.blockUI({ message: '<img src="Images/Common/Loading.gif" width=16 height=16/>登录中...', overlayCSS: {
            //                backgroundColor: '#777',
            //                opacity: '0.6'
            //            }
            //            });
            document.getElementById("__divRuning").style.display = '';
            document.getElementById("__divRuning").style.left = (document.body.clientWidth - 200) / 2; document.getElementById("__divRuning").style.top = (document.body.clientHeight - 47) / 2;
        },
        success: function(result) {     //回调函数，result，返回值
            if (result.d.IsLogin) {
                location = 'default.aspx';
            } else {
                alert('用户或密码错误!');
            }
        },
        complete: function(XMLHttpRequest, textStatus) {
            document.getElementById("__divRuning").style.display = 'none';
        },
        error: function() {
            //请求出错处理
        }
    });
    return false;
} 